import request from '@/utils/request';
import type { MenuResponse, MenuParams } from './type';
enum API {
    // 获取所有菜单
    GET_ALL_MENU = '/admin/acl/permission',
    // 新增菜单
    ADD_MENU = '/admin/acl/permission/save',
    // 更新菜单
    UPDATE_MENU = '/admin/acl/permission/update',
    // 删除菜单
    DELETE_MENU = '/admin/acl/permission/remove',
}

// 获取所有菜单
export const reqGetAllMenu = () =>
    request.get<any, MenuResponse>(API.GET_ALL_MENU);
// 新增或更新菜单
export const reqAddOrUpdateMenu = (data: MenuParams) => {
    if (data.id) {
        return request.put<any, any>(API.UPDATE_MENU, data);
    } else {
        return request.post<any, any>(API.ADD_MENU, data);
    }
};
// 删除菜单
export const reqDeleteMenu = (id: number) =>
    request.delete<any, any>(API.DELETE_MENU + `/${id}`);
